home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_09 / single2 / readme.txt < prev    next >
Encoding:
Text File  |  1994-08-07  |  4.5 KB  |  109 lines

  1. README.TXT file for NEWTEST code
  2. ================================
  3.  
  4. Thank you for using my code.  The following notes should help 
  5. you build the sample program successfully.
  6.  
  7. You should create a sub-directory RES, and move the 3 files
  8. NEWTEST.ICO, NEWTDOC.ICO, and NEWTEST.RC2 to this sub-directory.  
  9. (If you used PKUNZIP with the option -d, this will already have 
  10. been done for you.)
  11.  
  12. You should move the file COUT.ZIP to another directory, and 
  13. PKUNZIP it there.  This file contains the code and makefiles
  14. needed to build the cout libraries that NEWTEST uses.  My code
  15. assumes that this other directory is called COUT and is located
  16. at the same level as the directory into which you have unpacked
  17. the NEWTEST code (NTDIR in the diagram below):
  18.  
  19.      parent_directory ----|
  20.                           |
  21.                           |---- NTDIR
  22.                           |
  23.                           |---- COUT
  24.  
  25. If you use any other directory structure, you will need to edit
  26. NEWTEST.H so that the #include references for CSTRWND.H and 
  27. WINSTRM.H are correct.  You will also need to use the MSVC Project
  28. Options menu command to ensure that MSVC correctly picks up the
  29. reference to the COUT libraries in your particular directory 
  30. structure.
  31.  
  32. ----
  33.  
  34. The main test routines are in maintest.cpp.  I took two approaches to
  35. testing the MemoryObject and FarHeapBlock classes.  Firstly, I wanted to
  36. use MemoryObjects for a realistic test while at the same time thrashing
  37. the deallocation of memory.  I needed to allocate a large number of
  38. objects and then deallocate them in a different order.  I therefore
  39. implemented a simple tree-sorting routine that read a set of random
  40. numbers in from a file and sorted them into order.  I created the
  41. sort_node class, derived from MemoryObject, for this.  You will see that
  42. it is declared as FAR.  This is essential.  As MemoryObjects and their
  43. derived classes are created in Windows global memory, all pointers to
  44. them must be far pointers.  I wanted to fill a lot of FarHeapBlocks, to
  45. exercise things properly.  I therefore made each sort_node much bigger
  46. than it would normally need to be by including an array char filler
  47. [1000] in it.
  48.  
  49. I also decided to implement a string handling class like CString,
  50. provided as part of MFC.  Fortunately, Microsoft provide MFC source code
  51. with Visual C++.  Further, the MFC licensing conditions include the
  52. following phrase:
  53.  
  54. Microsoft grants you a non-exclusive royalty-free right to use and
  55. modify the source code contained in any Microsoft Foundation Classes
  56. source code file for purposes of creating a software product.  However,
  57. you may not include this code in source form (or any modified version of
  58. it) within any software product.
  59.  
  60. Thus, as the owner of a licensed version of Visual C++, I was able to
  61. take the majority of the MFC code that implements CString and modify it
  62. to work as a derived class of MemoryObject.  The new class is CMOString.
  63. The code for it is provided in the files cmostr.h and cmostr.cpp,
  64. included within the files that you can get from CUJ to support this
  65. article.  Please remember that you should have a legal copy of MFC to
  66. use the CMOString code and that the above licensing conditions apply to
  67. it.  (If you use the Symantec C++ compiler, you will have a legal copy
  68.  
  69.  
  70. of MFC, as Symantec license MFC from Microsoft.)  Microsoft has kindly
  71. given permission for me to include the code as part of this article.
  72.  
  73. The required modifications to CString were fairly straightforward.  All
  74. pointers needed to be explicitly declared as far pointers.  I had to
  75. modify the function CString::AllocBuffer so that it used
  76. CMemoryObject::AllocateBlock rather than the global new operator.
  77. Similarly, I had to modify SafeDelete to use CMemoryObject::ReturnBlock
  78. rather that the global delete operator.
  79.  
  80. The CComdtestApp::DoTest function, which does most of the testing,
  81. deliberately does not return all of the CMemoryObjects when it exits.
  82. This is to illustrate the handling of memory leakage.  I surround the
  83. call to DoTest with exception handling code, to trap any memory
  84. allocation errors (such as shortage of memory) identified by the
  85. program.
  86.  
  87. ----
  88.  
  89. Although I cannot guarantee support for my code, I would like 
  90. you to feel that you should ask me if you have any problems with 
  91. it.  
  92.  
  93. You can contact me via Compuserve.  My address there is
  94. 100265,3625.  
  95.  
  96. My postal address is:
  97.     
  98.     David Singleton
  99.     30 The Albany
  100.     Sunset Avenue
  101.     Woodford Green
  102.     Essex
  103.     IG8 0TJ
  104.     United Kingdom
  105.  
  106. Good luck
  107.  
  108. David Singleton
  109.